if (SERVER) then
	AddCSLuaFile("shared.lua")
	SWEP.AutoSwitchTo		= true
	SWEP.AutoSwitchFrom		= true
end

if (CLIENT) then	
	SWEP.Author				= "HLTV Proxy"
	SWEP.Instructions	= "Portable Bigbomb. \n This weapon only has one shot."
	SWEP.Contact		= ""
	SWEP.Purpose		= ""
	SWEP.Slot				= 4
	SWEP.SlotPos			= 5
	SWEP.ViewModelFOV		= 70
	SWEP.ViewModelFlip		= false
	SWEP.IconLetter			= "i"
	
	surface.CreateFont("HalfLife2", ScreenScale(60), 500, true, true, "HL2SelectIcons")
end

SWEP.PrintName			= "Worldslayer"
SWEP.HoldType			= "rpg"
SWEP.Base				= "weapon_cs_base"

SWEP.Spawnable			= false
SWEP.AdminSpawnable		= false

SWEP.ViewModel			= "models/weapons/v_rpg.mdl"
SWEP.WorldModel			= "models/weapons/w_rocket_launcher.mdl"

SWEP.Weight				= 5
SWEP.AutoSwitchTo		= false
SWEP.AutoSwitchFrom		= false

SWEP.Primary.Sound			= Sound("Weapon_RPG.Single")
SWEP.Primary.Recoil			= 15
SWEP.Primary.Damage			= 4107 // ALOT
SWEP.Primary.NumShots		= 5
SWEP.Primary.Cone			= 0.02
SWEP.Primary.ClipSize		= -1
SWEP.Primary.Delay			= 0.15
SWEP.Primary.DefaultClip	= -1
SWEP.Primary.Automatic		= false
SWEP.Primary.Ammo			= "none"

SWEP.Secondary.ClipSize		= -1
SWEP.Secondary.DefaultClip	= -1
SWEP.Secondary.Automatic	= false
SWEP.Secondary.Ammo			= "none"

SWEP.IronSightsPos 		= Vector(6.1, -14, 2.5)
SWEP.IronSightsAng 		= Vector(2.8, 0, 0)

/*---------------------------------------------------------
	PrimaryAttack
---------------------------------------------------------*/
function SWEP:PrimaryAttack()
	self.Weapon:SetNextSecondaryFire(CurTime() + self.Primary.Delay)
	self.Weapon:SetNextPrimaryFire(CurTime() + self.Primary.Delay)
	
	self.Weapon:EmitSound(self.Primary.Sound)
	if (SERVER) then
			local object = ents.Create("shot_worldslayer")
			object:SetOwner(self.Owner)
			object:SetPhysicsAttacker(self.Owner)
			object:SetPos(self.Owner:GetShootPos()+self.Owner:EyeAngles():Right()*5)
			object:SetAngles(self.Owner:EyeAngles())
			object:Spawn()
			object:Activate()
			object:GetPhysicsObject():SetVelocity(self.Owner:GetAimVector()*400000)
			object.Owner = self.Weapon.Owner
		if(self:GetUpgrade() > 0) then
			object.Upgraded = true	
		end
		
		self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK) 		// View model animation
		self.Owner:MuzzleFlash()								// Crappy muzzle light
		self.Owner:SetAnimation(PLAYER_ATTACK1)				// 3rd Person Animation
		
		local eyeang = self.Owner:EyeAngles()
		eyeang.pitch = eyeang.pitch - self.Primary.Recoil
		self.Owner:SetEyeAngles(eyeang)
	end
	
	self.Owner:ViewPunch(Angle(math.Rand(-0.2,0.2) * self.Primary.Recoil, math.Rand(-0.2,0.2) *self.Primary.Recoil, 0))
	if ((SinglePlayer() && SERVER) || CLIENT) then
		self.Weapon:SetNetworkedFloat("LastShootTime", CurTime())
	end
	if (SERVER) then
		self.Weapon:Remove()
	end
end

function SWEP:DrawWeaponSelection(x, y, wide, tall, alpha)
	self:PrintWeaponInfo(x + wide + 20, y + tall * 0.95, alpha)
	draw.SimpleText(self.IconLetter, "HL2SelectIcons", x + wide/2, (y + tall*0.2)-10, Color(255, 210, 0, 255), TEXT_ALIGN_CENTER)
	if (self:GetUpgrade() > 0) then
		draw.SimpleText("K", "CSKillIcons", x + wide-20, y + tall-25, Color(200,200, 200, 255), TEXT_ALIGN_CENTER)
	end
end

function SWEP:PrintWeaponInfo(x, y, alpha)

end

function SWEP:Upgrade(bool)
	self.Upgradestring = "Ability to shatter snipeshields"
end